//
//  ILEventReportManager.h
//  ILHome
//
//  Created by OrrHsiao on 2021/8/13.
//  Copyright © 2021 上海创米科技有限公司. All rights reserved.
//  事件上传 crash上传

#pragma mark - AliRefreshTokenError
/**
 AliRefreshTokenError 报错对应的errorCode 和 errorMessage
 
 错误码     含义
 0     账号未登录
 1     账号类型错误
 2     账号AuthCode无效（即Session失效）
 3     refreshToken过期，需要重新登录
 4     服务器相应的报文格式错误（请将request和response提工单）
 5     账号AuthCode校验错误
 -1     其他错误，请查看APIClient返回的具体业务错误或者通过detail字段查看
 
 */
#import <Foundation/Foundation.h>
#import "ILEventModel.h"

#import <DiDiPrism_Ability/PrismBehaviorModel.h>

#if defined(__has_include) && __has_include(<IMILabSDK_Log/ILLog.h>)
#import <IMILabSDK_Common/IMILabSDK_Common.h>
#else
#import "ILEventReportCfg.h"

#endif

typedef void(^ILEventReportCompletBlock)(NSError * _Nullable error);

NS_ASSUME_NONNULL_BEGIN


@protocol IEventConfigDelegate <NSObject>

///  动态接受config 变化
- (ILEventReportCfg * )configGetter;

/// 判断时间上报是否开启
- (BOOL) getEnable:(nonnull ILEventModel *)event;

@end


@interface ILEventReportManager : NSObject

@property (nonatomic, strong) NSMutableArray<PrismBehaviorItemModel*> *itemModels;
@property (nonatomic, weak) id<IEventConfigDelegate> configDelegate;


- (instancetype)init NS_UNAVAILABLE;
- (instancetype)new NS_UNAVAILABLE;
- (id)copy NS_UNAVAILABLE;
- (id)mutableCopy NS_UNAVAILABLE;

/// 获取实例
+ (instancetype)sharedManager;

/// 配置初始化
- (void)initConfig:(short)reportServer configDelegate:(id<IEventConfigDelegate>) configDelegate;


 -(void) updateUserInfoConfigWithUid:(NSString *) inputUid;

/// 更新配置信息，内部会去读取属性是否存在，存在则覆盖
- (void)serverChange:(short)server;

/// 上报事件 打点事件/错误事件均可
/// @param event 事件模型
/// @return 上报前验证结果，验证失败返回NO。如initConfig未调用、bEnable未开启、keyName属性未设置
- (BOOL)reportEvent:(nonnull ILEventModel *)event;


@end





NS_ASSUME_NONNULL_END
